<div class="panel panel-default panel-intro">
    {:build_heading()}

    <div class="panel-body">
        <div id="myTabContent" class="tab-content">
            <div class="tab-pane fade active in" id="one">
                <div class="widget-body no-padding">
                    <div id="toolbar" class="toolbar">
                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
                    </div>
                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
                           data-operate-detail="{:$auth->check('my_salary/detail')}"
                           width="100%">
                    </table>
                </div>
            </div>

        </div>
    </div>
</div>
<script src="/assets/libs/jquery/dist/jquery.min.js"></script>
<script>
    var tpls = JSON.parse('{$tpl}');
    var list = JSON.parse('{$list}');

    $(function(){
        console.log(123132);
        setTimeout(function(){
            var html = '<option value="0">请选择</option>';
            for (var i=0;i<list.length;i++){
                html += '<option value="'+list[i].id+'">'+list[i].title+'</option>';
            }
            $('#salary_benchmark_id').html(html);
        },3000)


    })


    function switch_item(){
        var salary_benchmark_id = $('#salary_benchmark_id').val();
        var html = '<option value="0">请选择</option>';
        for (var i=0;i<list.length;i++){
            if(list[i].id == salary_benchmark_id){
                for (var j=0;j<list[i].items.length;j++){
                    html += '<option value="'+list[i].items[j].id+'">'+list[i].items[j].name+'</option>';
                }
            }
        }
        $('#salary_benchmark_item_id').html(html);
    }
</script>

<script id="sourcetpl" type="text/html">
    <div class="row">
        <div class="col-xs-12">
            <div class="form-inline">
                <select class="form-control" id="salary_benchmark_id" name="salary_benchmark_id" onchange="switch_item()">
                </select>
                <select class="form-control" id="salary_benchmark_item_id" name="benchmark.salary_benchmark_item_id">

                </select>
            </div>
        </div>
    </div>
</script>
